<div class="modal" ng-controller="FlowableTaskListenersPopupCtrl">
  <div class="modal-dialog modal-wide">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true" ng-click="close()">&times;</button>
        <h2>{{ 'PROPERTY.PROPERTY.EDIT.TITLE' | translate }} "{{ property.title | translate }}"</h2>
      </div>
      <div class="modal-body">
        <!-- <div class="row row-no-gutter">
          <div class="col-xs-6">
            <div ng-if="translationsRetrieved" class="kis-listener-grid" ui-grid="gridOptions" ui-grid-selection></div>
            <div class="pull-right">
              <div class="btn-group">
                <a
                  class="btn btn-icon btn-lg"
                  rel="tooltip"
                  data-title="{{ ACTION.MOVE.UP | translate }}"
                  data-placement="bottom"
                  data-original-title=""
                  title=""
                  ng-click="moveListenerUp()"
                  ><i class="glyphicon glyphicon-arrow-up"></i
                ></a>
                <a
                  class="btn btn-icon btn-lg"
                  rel="tooltip"
                  data-title="{{ ACTION.MOVE.DOWN | translate }}"
                  data-placement="bottom"
                  data-original-title=""
                  title=""
                  ng-click="moveListenerDown()"
                  ><i class="glyphicon glyphicon-arrow-down"></i
                ></a>
              </div>
              <div class="btn-group">
                <a
                  class="btn btn-icon btn-lg"
                  rel="tooltip"
                  data-title="{{ ACTION.ADD | translate }}"
                  data-placement="bottom"
                  data-original-title=""
                  title=""
                  ng-click="addNewListener()"
                  ><i class="glyphicon glyphicon-plus"></i
                ></a>
                <a
                  class="btn btn-icon btn-lg"
                  rel="tooltip"
                  data-title="{{ ACTION.REMOVE | translate }}"
                  data-placement="bottom"
                  data-original-title=""
                  title=""
                  ng-click="removeListener()"
                  ><i class="glyphicon glyphicon-minus"></i
                ></a>
              </div>
            </div>
          </div>

          <div class="col-xs-6">
            <div ng-show="selectedListener">
              <div class="form-group">
                <label for="eventField">{{ 'PROPERTY.TASKLISTENERS.EVENT' | translate }}</label>
                <select id="eventField" class="form-control" ng-model="selectedListener.event">
                  <option>create</option>
                  <option>assignment</option>
                  <option>complete</option>
                  <option>delete</option>
                </select>
              </div>
              <div class="form-group">
                <label for="classField">{{ 'PROPERTY.TASKLISTENERS.CLASS' | translate }}</label>
                <input
                  type="text"
                  id="classField"
                  class="form-control"
                  ng-model="selectedListener.className"
                  ng-change="listenerDetailsChanged()"
                  placeholder="{{ 'PROPERTY.TASKLISTENERS.CLASS.PLACEHOLDER' | translate }}"
                />
              </div>
              <div class="form-group">
                <label for="expressionField">{{ 'PROPERTY.TASKLISTENERS.EXPRESSION' | translate }}</label>
                <input
                  type="text"
                  id="expressionField"
                  class="form-control"
                  ng-model="selectedListener.expression"
                  ng-change="listenerDetailsChanged()"
                  placeholder="{{ 'PROPERTY.TASKLISTENERS.EXPRESSION.PLACEHOLDER' | translate }}"
                />
              </div>
              <div class="form-group">
                <label for="delegateExpressionField">{{
                  'PROPERTY.TASKLISTENERS.DELEGATEEXPRESSION' | translate
                }}</label>
                <input
                  type="text"
                  id="delegateExpressionField"
                  class="form-control"
                  ng-model="selectedListener.delegateExpression"
                  ng-change="listenerDetailsChanged()"
                  placeholder="{{ 'PROPERTY.TASKLISTENERS.DELEGATEEXPRESSION.PLACEHOLDER' | translate }}"
                />
              </div>
            </div>
            <div ng-show="!selectedListener" class="muted no-property-selected" translate>
              PROPERTY.TASKLISTENERS.UNSELECTED
            </div>
          </div>
        </div>

        <div class="row row-no-gutter">
          <div class="col-xs-6">
            <div
              ng-if="translationsRetrieved"
              class="kis-field-grid"
              ui-grid="gridFieldOptions"
              ui-grid-selection
            ></div>
            <div class="pull-right">
              <div class="btn-group">
                <a
                  class="btn btn-icon btn-lg"
                  rel="tooltip"
                  data-title="{{ ACTION.MOVE.UP | translate }}"
                  data-placement="bottom"
                  data-original-title=""
                  title=""
                  ng-click="moveFieldUp()"
                  ><i class="glyphicon glyphicon-arrow-up"></i
                ></a>
                <a
                  class="btn btn-icon btn-lg"
                  rel="tooltip"
                  data-title="{{ ACTION.MOVE.DOWN | translate }}"
                  data-placement="bottom"
                  data-original-title=""
                  title=""
                  ng-click="moveFieldDown()"
                  ><i class="glyphicon glyphicon-arrow-down"></i
                ></a>
              </div>
              <div class="btn-group">
                <a
                  class="btn btn-icon btn-lg"
                  rel="tooltip"
                  data-title="{{ ACTION.ADD | translate }}"
                  data-placement="bottom"
                  data-original-title=""
                  title=""
                  ng-click="addNewField()"
                  ><i class="glyphicon glyphicon-plus"></i
                ></a>
                <a
                  class="btn btn-icon btn-lg"
                  rel="tooltip"
                  data-title="{{ ACTION.REMOVE | translate }}"
                  data-placement="bottom"
                  data-original-title=""
                  title=""
                  ng-click="removeField()"
                  ><i class="glyphicon glyphicon-minus"></i
                ></a>
              </div>
            </div>
          </div>

          <div class="col-xs-6">
            <div ng-show="selectedField">
              <div class="form-group">
                <label for="nameField">{{ 'PROPERTY.TASKLISTENERS.FIELDS.NAME' | translate }}</label>
                <input
                  type="text"
                  id="nameField"
                  class="form-control"
                  ng-model="selectedField.name"
                  placeholder="{{ 'PROPERTY.TASKLISTENERS.FIELDS.NAME.PLACEHOLDER' | translate }}"
                />
              </div>
              <div class="form-group">
                <label for="stringValueField">{{ 'PROPERTY.TASKLISTENERS.FIELDS.STRINGVALUE' | translate }}</label>
                <input
                  type="text"
                  id="stringValueField"
                  class="form-control"
                  ng-model="selectedField.stringValue"
                  ng-change="fieldDetailsChanged()"
                  placeholder="{{ 'PROPERTY.TASKLISTENERS.FIELDS.STRINGVALUE.PLACEHOLDER' | translate }}"
                />
              </div>
              <div class="form-group">
                <label for="expressionField">{{ 'PROPERTY.TASKLISTENERS.FIELDS.EXPRESSION' | translate }}</label>
                <input
                  type="text"
                  id="expressionField"
                  class="form-control"
                  ng-model="selectedField.expression"
                  ng-change="fieldDetailsChanged()"
                  placeholder="{{ 'PROPERTY.TASKLISTENERS.FIELDS.EXPRESSION.PLACEHOLDER' | translate }}"
                />
              </div>
              <div class="form-group">
                <label for="stringField">{{ 'PROPERTY.TASKLISTENERS.FIELDS.STRING' | translate }}</label>
                <textarea
                  id="stringField"
                  class="form-control"
                  ng-model="selectedField.string"
                  ng-change="fieldDetailsChanged()"
                  placeholder="{{ 'PROPERTY.TASKLISTENERS.FIELDS.STRING.PLACEHOLDER' | translate }}"
                ></textarea>
              </div>
            </div>
            <div ng-show="!selectedField" class="muted no-property-selected" translate>
              PROPERTY.TASKLISTENERS.FIELDS.EMPTY
            </div>
          </div>
        </div> -->
        <ul class="table-title">
            <li style="text-indent: 38px;">{{ 'PROPERTY.TASKLISTENERS.EVENT' | translate }}</li>
            <li>{{ 'PROPERTY.TASKLISTENERS.CLASS' | translate }}</li>
            <li>{{ 'PROPERTY.TASKLISTENERS.EXPRESSION' | translate }}</li>
            <li>{{ 'PROPERTY.TASKLISTENERS.DELEGATEEXPRESSION' | translate }}</li>
            <li style="text-align: center;">操作</li>
          </ul>
          <ul class="value-table">
            <li ng-repeat="selectedListener in taskListeners" id="$index">
                <div>
                    <span>
                      <i class="iconfont icon-edit"></i>
                    </span>
                    <select class="form-control no-border" ng-model="selectedListener.event" style="width:80%;">
                      <option>create</option>
                      <option>assignment</option>
                      <option>complete</option>
                      <option>delete</option>
                    </select>
                  </div>
                  <div>
                    <input
                      type="text"
                      class="form-control no-border"
                      ng-model="selectedListener.className"
                      ng-change="listenerDetailsChanged(selectedListener)"
                      placeholder="{{ 'PROPERTY.TASKLISTENERS.CLASS.PLACEHOLDER' | translate }}"
                    />
                  </div>
                  <div>
                    <input
                      type="text"
                      class="form-control no-border"
                      ng-model="selectedListener.expression"
                      ng-change="listenerDetailsChanged(selectedListener)"
                      placeholder="{{ 'PROPERTY.TASKLISTENERS.EXPRESSION.PLACEHOLDER' | translate }}"
                    />
                  </div>
                  <div>
                    <input
                      type="text"
                      class="form-control no-border"
                      ng-model="selectedListener.delegateExpression"
                      ng-change="listenerDetailsChanged(selectedListener)"
                      placeholder="{{ 'PROPERTY.TASKLISTENERS.DELEGATEEXPRESSION.PLACEHOLDER' | translate }}"
                    />
                  </div>
                  <div>
                    <span title="{{ 'ACTION.REMOVE' | translate }}"
                      ng-click="removeListener(selectedListener)">
                      <i class="iconfont icon-reduce_1"></i>
                    </span>
                    <span ng-if="$index == taskListeners.length-1" title="{{ 'ACTION.ADD' | translate }}"
                      ng-click="addNewListener()">
                      <i class="iconfont icon-add_1"></i>
                    </span>
                    <span title="配置字段" ng-click="addNewField(selectedListener)">
                      <i class="glyphicon glyphicon-pencil"></i>
                    </span>
                  </div>
            </li>
          </ul>
          <div ng-click="addNewListener()" ng-if="!taskListeners.length" class="add-data-property">没有配置任务监听器，点击此处添加</div>
          <ul class="table-title" style="margin-top: 30px;" ng-if="selectedListener">
            <li style="text-indent: 38px;">{{ 'PROPERTY.TASKLISTENERS.FIELDS.NAME' | translate }}</li>
            <li>{{ 'PROPERTY.TASKLISTENERS.FIELDS.STRINGVALUE' | translate }}</li>
            <li>{{ 'PROPERTY.TASKLISTENERS.FIELDS.EXPRESSION' | translate }}</li>
            <li>{{ 'PROPERTY.TASKLISTENERS.FIELDS.STRING' | translate }}</li>
            <li style="text-align: center;">操作</li>
          </ul>
          <ul class="value-table">
            <li ng-repeat="field in selectedListener.fields" id="$index">
                <div>
                    <span>
                      <i class="iconfont icon-edit"></i>
                    </span>
                    <input
                      style="width:80%;"
                      type="text"
                      class="form-control del-border"
                      ng-model="field.name"
                      placeholder="{{ 'PROPERTY.TASKLISTENERS.FIELDS.NAME.PLACEHOLDER' | translate }}"
                    />
                  </div>
                  <div>
                    <input
                      type="text"
                      class="form-control del-border"
                      ng-model="field.stringValue"
                      ng-change="fieldDetailsChanged(field)"
                      placeholder="{{ 'PROPERTY.TASKLISTENERS.FIELDS.STRINGVALUE.PLACEHOLDER' | translate }}"
                    />
                  </div>
                  <div>
                    <input
                      type="text"
                      class="form-control del-border"
                      ng-model="field.expression"
                      ng-change="fieldDetailsChanged(field)"
                      placeholder="{{ 'PROPERTY.TASKLISTENERS.FIELDS.EXPRESSION.PLACEHOLDER' | translate }}"
                    />
                  </div>
                  <div>
                    <input
                      class="form-control del-border"
                      ng-model="field.string"
                      ng-change="fieldDetailsChanged(field)"
                      rows="1"
                      style="line-height: 27px;"
                      placeholder="{{ 'PROPERTY.TASKLISTENERS.FIELDS.STRING.PLACEHOLDER' | translate }}"
                    ></input>
                  </div>
                  <div>
                    <span title="{{ 'ACTION.REMOVE' | translate }}"
                      ng-click="removeField(field)">
                      <i class="iconfont icon-reduce_1"></i>
                    </span>
                    <span ng-if="$index == selectedListener.fields.length-1" title="{{ 'ACTION.ADD' | translate }}"
                      ng-click="addListenerFields()">
                      <i class="iconfont icon-add_1"></i>
                    </span>
                  </div>
            </li> 
          </ul>
          <div ng-click="addListenerFields()" ng-if="selectedListener && !selectedListener.fields.length" class="add-data-property">没有配置字段，点击此处添加</div>
      </div>
      <div class="modal-footer">
          <button ng-click="save()" class="btn save-btn" translate>ACTION.SAVE</button>
          <button ng-click="cancel()" class="btn close-btn" translate>GENERAL.ACTION.CLOSE</button> 
      </div>
    </div>
  </div>
</div>
